local a = 10

local function test(a) 
	local b = 100
	local c = 200
	print(a, b, c)

	print(debug.getinfo(1).name)

	local i = 1
	while true do
		local name, val = debug.getlocal(1, i)
		if name == nil then
			break
		end

		print(name, val)
		i = i + 1
	end

	print("==================")
	debug.setlocal(1, 1, 20)
	i = 1
	while true do 
		local name, val = debug.getlocal(1, i)
		if name == nil then
			break
		end

		print(name, val)
		i = i + 1
	end
end

test(a)

function test_upvalue()
	local a = 10
	return function()
		a = a + 10
		return a
	end
end

local f = test_upvalue()
local name, val = debug.getupvalue(f, 1)
print(name, val)
print(f())

print("================")

local name, val = debug.getupvalue(f, 1)
print(name, val)

print("====set upvalue==========")
debug.setupvalue(f, 1, 40)
print(f())
